/* eslint-disable */
<template>
  <el-container>
    <header-user />
    <el-header class="header"><span>后台管理系统</span> </el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          @select="handleSelect"
        >
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-s-order"></i>
              <span>数据管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="1-1">书签管理</el-menu-item>
              <el-menu-item index="1-2">书签类型管理</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-pie-chart"></i>
              <span>访问统计</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="2-1">站点统计</el-menu-item>
              <el-menu-item index="2-2">访问量分析</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-container>
        <el-main>
          <router-view></router-view>
        </el-main>
        <el-footer>
          <div class="foot">@robin2365.cn</div>
        </el-footer>
      </el-container>
    </el-container>
  </el-container>
</template>

<script>
import { GetUserInfo } from '@/api/user';
import headerUser from '@/components/header.vue';

export default {
  name: 'login',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      userImgUrl: require("@/assets/user.png"),
      loginUser: { username: "", userid: "" },
    }
  },
  methods: {
    tofront () {
      this.$router.push("/front")
    },
    handleOpen (index) {
      console.log(index);
    },
    handleSelect (index) {
      console.log(index);
      if (index == "1-1") {
        this.$router.push("/management/bookmark")
      }
      else if (index == "1-2") {
        this.$router.push("/management/bookmarkType")
      }
      else if (index == "2-1") {
        this.$router.push("/management/visitAnalysis")
      }
      else if (index == "2-2") {
        this.$router.push("/management/websiteAnalysis")
      }
    },
    handleClose () {

    },
    handleLogout () {
      localStorage.removeItem('authorization');
      this.$router.push("/login")
    }
  },
  components: {
    "header-user": headerUser,
  },


  mounted () {
    let token = localStorage.getItem("authorization");
    var user = GetUserInfo(token);
    user.then((result) => {
      this.$set(this.loginUser, "username", result.data[0].username)
    });
  }


}
</script>

<style scoped>
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 80px;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  line-height: 200px;
  height: calc(100vh - 60px);
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  /* line-height: 160px; */
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}
.header {
  text-align: left;
  padding-left: 20px;
  color: white;
  background-color: rgb(64, 158, 255);
  line-height: 60px;
  vertical-align: middle;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.foot {
  line-height: 60px;
}
</style>
